package lanqiaoDemo1;

import java.util.*;

/**
 * @Author liangzai
 * @Description:
 *
 * */

public class Main {
    //分布式队列
    public static void main1(String[] args) {
        Scanner scanner = new Scanner(System.in);
        Integer n = scanner.nextInt();
        List<Queue<Integer>> list = new ArrayList<Queue<Integer>>();
        for (int i = 0; i < n; i++) {
            list.add(new ArrayDeque<>(20000));
        }
        while (true) {
            String operate = scanner.next();
            if(operate.equals("add")){
                int key = scanner.nextInt();
                add(list,key);
            }else if(operate.equals("sync")){
                int key = scanner.nextInt();
                sync(list,key);
            }else if(operate.equals("query")){
                query(list);
            }
        }
    }

    private static void add(List<Queue<Integer>> list,int key){
        list.get(0).add(key);
    }

    private static void sync(List<Queue<Integer>> list, int key){
        int len = list.get(0).size();
        int index = list.get(key).size();
        if(len != index){
            int elem = 0;
            for (int each : list.get(0)) {
                elem = each;
                index--;
                if(index<0){
                    break;
                }
            }
            list.get(key).add(elem);
        }
    }

    private static void query(List<Queue<Integer>> list){
        int min = list.get(0).size();
        for(Queue<Integer> each : list){
            min = Math.min(each.size(),min);
        }
        System.out.println(min);
    }

    public static void main2(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] count = new int[n];
        while (scanner.hasNext()) {
            String operate = scanner.next();
            if(operate.equals("add")){
                int key = scanner.nextInt();
                count[0]++;
            }else if(operate.equals("sync")){
                int index = scanner.nextInt();
                count[index] = Math.min(count[index]+1,count[0]);
            }else {
                int min = Integer.MAX_VALUE;
                for (int i = 0; i < n; i++) {
                    min = Math.min(min,count[i]);
                }
                System.out.println(min);
            }
        }
    }

    //最有分组
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        double p = scanner.nextDouble();
        int min = N;
        int MIN = 1;
        double ans = Double.MAX_VALUE;
        for (int i = 2; i < N; i++) {
            if(N%i==0){
                double key = ((double)N/i)*(1 + ( 1 - (Math.pow(1-p,i) ) )*i);
                if(key<ans){
                    ans = key;
                    MIN = i;
                }
            }
        }
        System.out.println(MIN);
    }
}//(((double) N / k) * (1 + (1 - Math.pow(1 - p, k)) * k));
